from sqlalchemy import Column, String, Integer, Text, SmallInteger, DateTime
from sqlalchemy.schema import Index
from sqlalchemy.sql import func
from interview_voice_project.__002__db_helper_parse.model.base import Base


class TbScoringTemplate(Base):
    __tablename__ = 'tb_scoring_template'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键ID')
    template_key = Column(String(64), nullable=False, unique=True, comment='模板键，例如 技术岗/产品岗')
    weights_json = Column(Text, nullable=False, comment='权重JSON，例如 {"professional":0.5,"communication":0.2,"project":0.3}')
    description = Column(Text, nullable=True, comment='模板描述')
    default_flag = Column(SmallInteger, default=0, comment='是否默认模板：0否 1是')
    create_time = Column(DateTime, default=func.now(), comment='创建时间')
    update_time = Column(DateTime, default=func.now(), onupdate=func.now(), comment='更新时间')

    __table_args__ = (
        Index('idx_template_key', 'template_key'),
        Index('idx_default_flag', 'default_flag'),
    )
